package com.ruicar.afs.cloud.apply.common.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruicar.afs.cloud.common.core.entity.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * @description: 挂靠单位申请表
 * @author: sijun.yu
 * @date: 2020/5/11 18:01
 */
@Data
@TableName(value = "apply_affiliated_unit", autoResultMap = true)
@Accessors(chain = true)
public class ApplyAffiliatedUnit extends BaseEntity<ApplyAffiliatedUnit> {

    /**
     * 申请编号
     */
    private String applyNo;
    /**
     * 车辆ID
     */
    private Long carId;
    /**
     * 挂靠方式
     */
    private String affiliatedType;
    /**
     * 挂靠单位ID
     */
    private String affiliatedId;
    /**
     * 挂靠公司/个体工商户名称/运营公司
     */
    private String affiliatedName;
    /**
     * 社会统一信用代码
     */
    private String socUniCrtCode;
    /**
     * 法人姓名
     */
    private String legalName;
    /**
     * 法人联系电话
     */
    private String legalPhone;
    /**
     * 运营许可证有效期
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date licenceEndDate;
    /**
     * 注册地址-省份
     */
    private String registProvince;
    /**
     * 注册地址-城市
     */
    private String registCity;
    /**
     * 注册地址-详细
     */
    private String registAddress;
    /**
     * 平台ID
     */
    private String platformId;
    /**
     * 合作平台
     */
    private String cooperPlatform;
    /**
     * 回显页面翻译用  注册地址
     */
    @TableField(exist = false)
    private String[] registAddressTemp;
    /**
     *  合同修改标识
     */
    private String modifyFlag;
    /**
     * 详细注册地址
     */
    @TableField(exist = false)
    private String registDetailAddress;

    public String[] getRegistAddressTemp() {
        if (StringUtils.isEmpty(this.registProvince) && StringUtils.isEmpty(this.registCity)) {
            return null;
        } else {
            return new String[]{this.registProvince, this.registCity};
        }
    }

    public void setRegistAddressTemp(String[] registAddressTemp) {
        if (registAddressTemp != null) {
            if (registAddressTemp.length >= 1) {
                this.registProvince = registAddressTemp[0];
            }
            if (registAddressTemp.length >= 2) {
                this.registCity = registAddressTemp[1];
            }
            this.registAddressTemp = registAddressTemp;
        }
    }
}
